package tech.aistar.model.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.Date;

/**
 * 本类用来演示:
 *
 * @author: success
 * @date: 2021/4/28 10:52 上午
 */
@Entity
@Table(name = "t_users")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Users implements Serializable {
    @Id
    @GeneratedValue
    private Integer id;

    //@Column(name = "username")
    @NotBlank(message = "用户名不能为空",groups = {Group1.class})
    private String username;

    //@Size(min = 4,max = 6,message = "密码必须是[4~6]位",groups = {Group2.class,Group1.class})
    @Pattern(regexp = "[a-z0-9]{4,6}",message = "密码必须是[4~6]位",groups = {Group1.class,Group2.class})
    private String password;

    private Integer power;

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date birthday;
}
